/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.oracleandsxnd.erp.xsd.web;

import com.oracleandsxnd.erp.common.persistence.Page;
import com.oracleandsxnd.erp.common.persistence.TableSplitResult;
import com.oracleandsxnd.erp.common.web.AjaxResult;
import com.oracleandsxnd.erp.common.web.BaseController;
import com.oracleandsxnd.erp.xsd.entity.XsglSale;
import com.oracleandsxnd.erp.xsd.entity.XsglSaleVoice;
import com.oracleandsxnd.erp.xsd.service.XsglSaleService;
import com.oracleandsxnd.erp.xsd.service.XsglSaleVoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 发票管理Controller
 * @author 发票管理
 * @version 2019-12-21
 */
@Controller
@RequestMapping(value = "xsd_xsglSaleVoice")
public class XsglSaleVoiceController extends BaseController {

	@Autowired
	private XsglSaleVoiceService xsglSaleVoiceService;
	@Autowired
	private XsglSaleService xsglSaleService;
	@RequestMapping(value = "form")
	public String form(String saleid, Model model) {
		XsglSale xsglSale=xsglSaleService.get(saleid);
		model.addAttribute("xsglSale",xsglSale);
		return "erp/xsd/xsglSaleVoiceForm";
	}
	@RequestMapping(value = {""})
	public String list(XsglSaleVoice xsglSaleVoice, HttpServletRequest request, HttpServletResponse response, Model model) {
		return "erp/xsd/xsglSaleVoiceList";
	}

	@RequestMapping(value = {"listData"})
	@ResponseBody
	public Object listData(XsglSaleVoice xsglSaleVoice , HttpServletRequest request, HttpServletResponse response){
		Page<XsglSaleVoice> page = xsglSaleVoiceService.findPage(new Page<XsglSaleVoice>(request, response), xsglSaleVoice);
		TableSplitResult<XsglSaleVoice> result=new TableSplitResult<XsglSaleVoice>(page.getPageNo(), page.getCount(), page.getList());
		return  result;
	}
	@RequestMapping(value = "save")
	public String save(XsglSaleVoice xsglSaleVoice) {

		xsglSaleVoiceService.save(xsglSaleVoice);
		return "redirect:/xsd_xsglSaleVoice";
	}

	@RequestMapping(value = "delete")
	@ResponseBody
	public AjaxResult  delete(XsglSaleVoice xsglSaleVoice, RedirectAttributes redirectAttributes) {
		xsglSaleVoiceService.delete(xsglSaleVoice);
		return success();
	}

}